package zilvic.game.room.entity.trigger;

import java.util.HashMap;

/**
 *
 * @author Duncan
 */
public class ActionStore {
    /** The single instance of this class */
    private static ActionStore single = new ActionStore();

    /**
     * Get the single instance of this class
     *
     * @return The single instance of this class
     */
    public static ActionStore get() {
            return single;
    }

    /** The cached action map, from reference to action instance */
    private HashMap actions = new HashMap();

    /**
     * Retrieve an action from the store
     *
     * @param ref The reference to the action
     * @return The referenced action.
     */
    public Action get(String ref) {
        return (Action) actions.get(ref);
    }

    /**
     * Store an action in the store.
     *
     * @param ref The reference to the action
     * @param action The action to store.
     * @return A reference to this.
     */
    public ActionStore set(String ref, Action action) {
        actions.put(ref, action);
        return this;
    }
}
